<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    button.click {
      background-color: yellow;
    }
    div.contain{
      width: 100px;
      height: 100px;
      background-color: red;
      display: none;
    }
    div.click{
      display:block;
    }

  </style>
  
</head>
<body>
  <!-- <button>1</button>
  <button>2</button>
  <button>3</button>
  <div class="contain">111</div>
  <div class="contain">222</div>
  <div class="contain">333</div>
  
    var but =document.getElementsByTagName('button')[0];
    var div0 =document.getElementsByClassName('contain');
    // for(let i=0;i<but.length;i++){
    //   but[i].onclick=function(){
    //     but[i].setAttribute('class','click')
    //   }
    // }
    div0.setAttribute('class','click') -->
  <div></div>
  <script>
    var div = document.getElementsByTagName('div')[0];
    div.setAttribute('class','click')
  </script>
</body>
</html>